home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / misc / vpan100.zip / VPUTIL.CPP < prev    next >
C/C++ Source or Header  |  1995-01-18  |  3KB  |  126 lines

  1. //
  2. //         UTILITY BOXES FOR VirtualPanels APPLICATIONS
  3. //    
  4. //         VPUTIL.CPP: 
  5. //            FUNCTIONS :
  6. //            void DisplayMessage(char *title,char *mess)
  7. //            void DisplayErrorMessage(char *mess)
  8. //            int  Confirm(char *mess)
  9. //            void far bpHelp()
  10. //
  11. //                       |     Written by O.Rasizade
  12. //                 |       1993
  13. //                       |
  14. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  15. #include "vphead.h"    // must be included first
  16. #pragma hdrstop
  17.  
  18.  
  19. #include <vpbase.h>
  20. //#include <vpboard.h>
  21. #include <vpoutbox.h>
  22. //#include <vpinbox.h>
  23. //#include <vpindic.h>
  24. //#include <vpgraph.h>
  25. #include <vpbutt.h>
  26. #include <vputil.h>
  27.  
  28. //------------------------- DISPLAY MESSAGE BOX ---------
  29.  
  30. void _Cdecl DisplayMessage(char *title,char *mess)
  31. {
  32.  beep;
  33. Outbox Message(maxx>>2,maxy>>2,POPUP,title,strlen(mess),1,FRAMED,procNULL,0,1,0,1);
  34.  Message.Paint();
  35.  Message.Put(mess,1);
  36.  getch();
  37.  Message.Remove();
  38. }
  39.  
  40. //------------------------- DISPLAY ERROR MESSAGE BOX ----
  41.  
  42. void _Cdecl DisplayErrorMessage(char *mess)
  43. {
  44.  beep;
  45. Outbox Message(maxx>>2,maxy>>2,POPUP,"Error",strlen(mess),1,FRAMED,
  46.     procNULL,0,1,0,1,errboxcolors,errcolors);
  47.  Message.Paint();
  48.  Message.Put(mess);
  49.  getch();
  50.  Message.Remove();
  51. }
  52.  
  53. //--------------------------------  CONFIRM BOX ----------
  54. //----- returns FALSE if 'No' button was pressed,
  55. //-----         TRUE     'Yes'
  56. int resp;     // Status register 1- Yes,  0 - No
  57. butsystem *pbsYN;
  58.  
  59. void far bpYes(void)
  60.     { resp=1; pbsYN->SendMessage(MSG_EXIT);} // exit Loop
  61. void far bpNo(void)
  62.     { resp=0; pbsYN->SendMessage(MSG_EXIT);} // exit Loop
  63.  
  64. int _Cdecl Confirm(char *mess,int dflt)
  65. {
  66. resp = dflt;
  67. pbsYN = new butsystem;
  68.  
  69. Outbox Ask( maxx>>2, maxy>>2, POPUP, "Confirm",
  70.             strlen(mess)+2, 5,  // size of box
  71.             FRAMED, procNULL, 0,1, 0,1);// title and text fonts
  72. butgrp YesNo( (Ask.xmax+Ask.x0-110)>>1, Ask.ymax-40, 50, 21, HORIZ, 10);
  73.  button Yes("Yes",'y','Y',bpYes);
  74.  button No("No",'n','N',bpNo);
  75.  
  76.  Ask.Paint();
  77.  Ask.Putn("");
  78.  Ask.Put( mess,1);
  79.  YesNo.Paint();
  80.  pbsYN->NextButton();
  81.  if ( dflt == NO )
  82.    pbsYN->NextButton();
  83.  pbsYN->Loop(procDummy);
  84.  delete pbsYN;
  85.  Ask.Remove();
  86.  return resp;    // return TRUE if Yes, FALSE if No
  87. }
  88.  
  89.  
  90. //----------------------------- HELP ---
  91.  
  92. extern Outbox *obxHelp;
  93.  
  94. void far _Cdecl bpHelp(void)
  95. {        // popup output box
  96. #define    hN  8    // number of rows of help text
  97. int i;
  98.   //------------- Help text
  99. char *txt[2][hN]=
  100.  {
  101.  {"Alt-F3","Ctrl-F5","F6","Left,Right,Up,Down","Ctrl-Left,Right,Up,Down",
  102.     "Tab","Shift-Tab","Esc"},
  103.   {"close window", "start dragging object", "switch between objects",
  104.    "quick drag", "slow drag",
  105.    "go to next button group", "go to prev. button group",
  106.    "quit"}
  107.   };
  108.  
  109.  obxHelp->Paint();
  110.  obxHelp->MkActive();
  111.         // hilight text output
  112.  for (i=0;i<hN;i++) obxHelp->Printfn(1,txt[0][i]);
  113.  
  114.  obxHelp->GotoXY(0,0);
  115.  obxHelp->SetTextJustify(RIGHT_TEXT);    // normal text output
  116.  for (i=0;i<hN;i++) obxHelp->Putn(txt[1][i]);
  117.  
  118.  obxHelp->GotoXY(0,-1);     // put cursor at bottom of box
  119.  obxHelp->SetTextJustify(CENTER_TEXT);
  120.  obxHelp->SetTextColor(LIGHTGREEN);
  121.  obxHelp->Put("Press any key...");
  122.  obxHelp->SetTextColor(WHITE);
  123.  getch();
  124.  obxHelp->Remove();
  125. }//--- END of bpHelp() ---
  126.